﻿#pragma once
#include "includeBase.h"

#include "PropertyProvider.h"
#include <QtPropertyBrowser/QtTreePropertyBrowser>

/// <summary>
/// 提供 PropertyEditor 的管理
/// </summary>
class PropertyManager
{
public:
    PropertyManager();

public:
    static PropertyManager& get(const QString& name = "");
    void init(QtTreePropertyBrowser* editor);

    void setCurrent(shared_ptr<PropertyProvider> provider);
    void close();

public:
    QtTreePropertyBrowser* editor() const { return editor_; }

protected:
    QtTreePropertyBrowser* editor_;
    // 不能删除 provider_，这是唯一指针计数的地方
    shared_ptr<PropertyProvider> provider_ = nullptr;
};
